package view;

import java.awt.CardLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;

/**
 * This class holds information on the layout of the main menu
 * 
 * @author Stephanie
 *
 */
public class MainMenu extends JPanel {
	
	public static final String ID = "MAIN_MENU";
	
	private MainFrame mainFrame;
	
	private Image img;
	
	private JButton newGameButton;
	private JButton exitButton;
	private JButton changeControllerButton;
	private JButton loadButton;
	
	public MainMenu( MainFrame mainFrame ) {
		this.mainFrame = mainFrame;
		
		img = new ImageIcon("images/medusa.jpg").getImage();
		
		setSize(800,600);
		setLocation(0,0);
		setLayout(null);
		setVisible(true);
		
		newGameButton = new JButton("New Game");
		newGameButton.setSize(250,30);
		newGameButton.setLocation(275,100);
		newGameButton.setVisible(true);
				
		exitButton = new JButton("Exit");
		exitButton.setSize(250,30);
		exitButton.setLocation(275,400);
		exitButton.setVisible(true);
		
		changeControllerButton = new JButton("Change Controller Configuration");
		changeControllerButton.setSize(250,30);
		changeControllerButton.setLocation(275,300);
		changeControllerButton.setVisible(true);
		
		loadButton = new JButton("Load Game");
		loadButton.setSize(250,30);
		loadButton.setLocation(275,200);
		loadButton.setVisible(true);
		
		add(newGameButton);
		add(loadButton);
		add(changeControllerButton);
		add(exitButton);
	}
	
	public void addNewGameListener( ActionListener listener ) {
		newGameButton.addActionListener( listener );
	}
	
	public void addLoadListener( ActionListener listener ) {
		loadButton.addActionListener(listener);
	}
	
	public void addChangeControllerListener( ActionListener listener ) {
		changeControllerButton.addActionListener(listener);
	}

	public void addExitListener( ActionListener listener ) {
		exitButton.addActionListener(listener);
	}
	
	public void paintComponent(Graphics g) {
		g.drawImage(img,0,0,null);
	}
}
